<!DOCTYPE html>
<html lang="en">
<head>
    <title></title>  <link rel="icon" href="/template/pc1/images/wmh_favicon.ico" type="image/x-icon" />
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimal-ui">
    <meta name="author" content="">
    <% include("../inc/list_css.html"){}%>
</head>
<body>
<div class="ibox ">
    <div class="ibox-title">
        <div class="pull-left mbx navbar_title">
            <span>品牌列表 </span>
            <span class="line">/</span>
            品牌管理
        </div>
    </div>

    <div class="ibox-content">
        <div class="wrapper wrapper-content">
            <input type="hidden" name="memberLevel" id="memberLevel" value="1">
            <div class="row">
                <div class="col-sm-12" >
                    <div class="alert alert-warning alert-dismissable">
                        <button aria-hidden="true" data-dismiss="alert" class="close" type="button">×</button>
                        1.在"更新上级"时，切勿把下级调整成<b>同一条线中其上级的上级</b>.<br>
                        2.在搜索框输入用户名,编码,推荐人昵称,推荐人编码等,即可检索对应的信息.
                    </div>
                    <div class="btn-group margin-vertical-20_10">
                        <button class="member hive-btn-md-large hive-btn-primary" type="button" data="1">正式会员</button>
                        <button class="member hive-btn-md-large hive-btn-primary" type="button" data="2">准会员</button>
                        <button type="button" class="hive-btn-md-large hive-btn-primary" onclick="exportMember()">导出</button>
                    </div>
                    <table data-toggle="table " id="cpTableEvents" data-show-export="true" class=" table-striped table-no-bordered fixed-table-container table-row-border-color table-hovered table-hover">
                        <thead class="table-header">
                        <tr>
                            <th data-field="number" data-formatter="numberFormatter">序号</th>
                            <th data-field="username">用户名</th>
                            <th data-field="realname">真实姓名</th>
                            <th data-field="code">编码</th>
                            <th data-field="sex" data-formatter="sexFormatter">性别</th>
                            <th data-field="memberRankname">会员等级</th>
                            <th data-field="phone">联系方式</th>
                            <th data-field="topUsername">推荐人昵称</th>
                            <th data-field="topRealname">推荐人姓名</th>
                            <th data-field="topCode">推荐人编码</th>
                            <th data-field="createDate">注册日期</th>
                            <th data-field="isAccountLocked" data-formatter="stateFormatter">状态</th>
                            <th data-field="head" data-formatter="opFormatter" data-halign="center"  data-align="center" data-width="160">操作</th>
                        </tr>
                        </thead>

                    </table>

                </div>
            </div>
        </div>
    </div>
</div>
<% include("../inc/list_js.html"){}%>

<div class="modal inmodal fade" id="addPoint" tabindex="-1" role="dialog"  aria-hidden="true">
    <input type="hidden" id="memberId_p" value=""/>
    <div class="modal-dialog modal-lg" style="width: 300px;">
        <div class="modal-content" style="width: 300px;">
            <div class="modal-header" style="height: 0px">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                <h5 class="modal-title" style="font-size: 1.4rem">积分充值</h5>
            </div>
            <div class="modal-body" style="text-align: center;">
                <input name="point" placeholder="请输入充值积分" value="" onkeyup="value=value.replace(/[^\d]/g,'')" onblur="this.value=this.value.replace(/[^\d]/g,'')" style="height: 35px;">
            </div>

            <div class="modal-footer" style="text-align: center">
                <button type="button" class="btn btn-primary" id="sureAddPoint">确认充值</button>
                <button type="button" class="btn btn-white" data-dismiss="modal">取消</button>
            </div>
        </div>
    </div>
</div>
<div class="modal inmodal fade" id="addMoney" tabindex="-1" role="dialog"  aria-hidden="true">
    <input type="hidden" id="memberId_d" value=""/>
    <div class="modal-dialog modal-sm">
        <div class="modal-content">
            <div class="modal-header" style="height: 0px">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                <h5 class="modal-title" style="font-size: 1.4rem">预存款充值</h5>
            </div>
            <div class="modal-body" style="text-align: center;">
                <input name="deposit" placeholder="请输入充值金额" value="" onkeyup="value=value.replace(/[^\d.]/g,'')" onblur="this.value=this.value.replace(/[^\d.]/g,'')" style="height: 35px;">
            </div>
            <div class="modal-footer" style="text-align: center">
                <button type="button" class="btn btn-primary" id="sureAddMoney">确认充值</button>
                <button type="button" class="btn btn-white" data-dismiss="modal">取消</button>
            </div>
        </div>
    </div>
</div>
<div class="modal inmodal fade" id="changeParent" tabindex="-1" role="dialog"  aria-hidden="true">
    <input type="hidden" id="memberId_cp" value=""/>
    <div class="modal-dialog modal-sm">
        <div class="modal-content">
            <div class="modal-header" style="height: 0px">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                <h5 class="modal-title" style="font-size: 1.4rem">修改直接上级</h5>
            </div>
            <div class="modal-body" style="text-align: center;">
                <input name="parentcode" placeholder="请输入上级会员编码" value="" onkeyup="value=value.replace(/[^\d.]/g,'')" onblur="this.value=this.value.replace(/[^\d.]/g,'')" style="height: 35px;">
                <div id="msg" style="color: #ff0000"></div>
            </div>
            <div class="modal-footer" style="text-align: center">
                <button type="button" class="btn btn-primary" id="sureChangeParent">确认修改</button>
                <button type="button" class="btn btn-white" data-dismiss="modal">取消</button>
            </div>
        </div>
    </div>
</div>

<script>
    function opFormatter(value, row, index){
        var html ='';
        html = '<a href="javascript:void(0)" onclick="a(\''+row.id+'\',\''+row.username+'\');" ><i class="fa fa-angle-double-down" data-toggle="tooltip" data-placement="top" title="下级推荐树"></i>下级</a>';
        html += '<a href="javascript:void(0)" onclick="getParentUsername(\''+row.id+'\');" ><span style="margin-left:10px;"><i class="fa fa-angle-double-up" data-toggle="tooltip" data-placement="top" title="上级推荐关系"></i></span>上级</a>';
        html += '<a href="javascript:void(0)" onclick="getUserBackMoney(\''+row.id+'\');" ><span style="margin-left:10px;"><i class="fa fa-spinner" data-toggle="tooltip" data-placement="top" title="分销金额列表"></i></span>分销金额</a>';
        /*html += '<a href="javascript:void(0)" onclick="addMoney(\''+row.id+'\');" ><span style="margin-left:10px;" data-toggle="modal" data-target="#addMoney"><i class="fa fa-cny" data-toggle="tooltip" data-placement="top" title="预存款充值"></i></span>预存款充值</a>';
        html += '<a href="javascript:void(0)" onclick="addPoint(\''+row.id+'\');" ><span style="margin-left:10px;" data-toggle="modal" data-target="#addPoint"><i class="fa fa-btc" data-toggle="tooltip" data-placement="top" title="积分充值"></i></span>积分充值</a>';
        html += '<a href="javascript:void(0)" onclick="resetMemberPassword(\''+row.id+'\');" ><span style="margin-left:10px;"><i class="fa fa-hand-paper-o" data-toggle="tooltip" data-placement="top" title="重置用户密码"></i></span>重置用户密码</a>';*/
        return html;
    }


    //会员导出
    function exportMember(){
        var memberLevel=$("#memberLevel").val();
        window.location.href='exportMember?memberLevel='+memberLevel+'';
    }
    function sexFormatter(value) {
        if(value){
            if(value == 1)
                return '男';
            if(value == 2)
                return '女';
            if(value == 0 || value == null)
                return '未知';
        }else{
            return '未知';
        }
    }

    function a(id,name) {
        parent.layer.open({
            type: 2,
            title: name+'的分销关系',
            shadeClose: true,
            shade: 0.8,
            area: ['70%', '98%'],
            content: '/mall/admin/businessmember/fxrelation?id='+id //iframe的url
        });
    }

    function closep(id,type){
        var msg = '';
        if(type == 1){
            msg = '确定要锁定该用户吗？';
        }else{
            msg = '确定要解锁该用户吗？'
        }
        parent.layer.confirm(msg, {
            shade: [0.3,'#fff'],//0.1透明度的白色背景
            btn: ['是','否']
        }, function(){
            $.post('close',{"id":id},function (data) {
                if(data.success){
                    parent.layer.msg('设定成功');
                }
            });
        });

    }
    function resetMemberPassword(id){

        parent.layer.confirm('确定要重置该用户密码吗？', {
            btn: ['是','否']
        }, function(){
            $.post('resetMemberPassword',{"id":id},function (data) {
                if(data.success){
                    parent.layer.msg('设置成功');
                }
            });
        }, function(){

        });

    }

    function getParentUsername(id) {

        parent.layer.open({
            type: 2,
            title: '父推荐关系',
            shadeClose: true,
            shade: 0.8,
            area: ['80%', '90%'],
            content: '/mall/admin/businessmember/getAllParentForm?id='+id //iframe的url
        })

//        $.post('${base}/html/getUserParent.jsp',{"pid":id},function (data) {
//            toastr.success(data, '上级信息')
//        });
    }

    function getUserBackMoney(id) {

        parent.layer.open({
            type: 2,
            title: '返佣列表',
            shadeClose: true,
            shade: 0.8,
            area: ['80%', '70%'],
            content: '/mall/admin/businessmember/getUserBackMoneyForm?id='+id //iframe的url
        })
    }

    //预存款管理
    function addMoney(id){
        $("#memberId_d").val(id);
    }
    $("#sureAddMoney").click(function () {
        var memberId=$("#memberId_d").val();
        var deposit=$("input[name='deposit']").val();
        if(!deposit){
            layer.msg("充值金额不能为空!");
            return;
        }
        layer.confirm('您确定要给该用户充值吗? 充值后将不可撤销!', {
            btn: ['是','否'] //按钮
        }, function(){
            $.ajax({
                url: "addmoney",
                type: 'GET',
                data:{
                    "memberId":memberId,
                    "deposit":deposit
                },
                success: function(data){
                    if(data.code == 1){
                        //注册错误
                        layer.msg(data.desc);
                    }else if (data.code == 0){
                        layer.msg('充值成功!');
                        window.location.reload();

                    }
                }});
        });

    });

    //积分管理
    function addPoint(id){
        $("#memberId_p").val(id);
    }
    $("#sureAddPoint").click(function () {
        var memberId=$("#memberId_p").val();
        var point=$("input[name='point']").val();
        if(!point){
            layer.msg("充值积分不能为空!");
            return;
        }

        layer.confirm('您确定要给该用户充值吗? 充值后将不可撤销!', {
            btn: ['是','否'] //按钮
        }, function(){
            $.ajax({
                url: "addpoint",
                type: 'GET',
                data:{
                    "memberId":memberId,
                    "point":point
                },
                success: function(data){
                    if(data.code == 1){
                        //注册错误
                        layer.msg(data.desc);
                    }else if (data.code == 0){
                        layer.msg('充值成功!');
                        window.location.reload();

                    }
                }});
        });

    });

    //上级管理
    function changeParent(id){
        $("#memberId_cp").val(id);
    }
    $("#sureChangeParent").click(function () {
        var memberId=$("#memberId_cp").val();
        var parentcode=$("input[name='parentcode']").val();
        if(!parentcode){
            layer.msg("上级code不能为空!");
            return;
        }
        var con=confirm("您确定修改吗? 成功后不可撤销!");
        if(!con){
            return;
        }
        $.post("changeParent",{"id":memberId,"pcode":parentcode},function (data) {
            if(data.code == 1){
                toastr.success(data.desc, '提示')
            }else if (data.code == 0){
                toastr.success('修改成功', '提示')
                $('#msg').html(data.desc);
            }
        });
    });



    function numberFormatter(value, row, index){
        return index+1;
    }

    function stateFormatter(value){
        if(value){
            return "锁定";
        }else{
            return "正常";
        }
    }

    (function() {
        $(".wrapper").tooltip({selector:"[data-toggle=tooltip]",container:"body"});

        $('.member').on('click',function (e) {
            $('.member').removeClass('btn-primary').addClass('btn-white');
            $(this).removeClass('btn-white').addClass('btn-primary');

            $('#cpTableEvents').bootstrapTable("refresh",{query: {memberLevel: $(this).attr('data'),profitDate:$("#start").val()}});
            $("#memberLevel").attr("value",$(this).attr('data'))
        });
        $('#cpTableEvents').bootstrapTable({
            url: "ajaxlist",
            dataType: 'json',
            contentType: 'application/json',
            search: true,
            searchAlign: 'right',
            pagination: true,
            showRefresh: true,
            pageSize: 20,
            showToggle: false,//是否显示card/table切换按钮
            showColumns: true,//是否显示内容列下拉框
            pageList: [20, 50, 100],
            iconSize: 'outline',
            toolbar: '#eventsToolbar',
            paginationHAlign: 'right', //right, left
            paginationVAlign: 'bottom',
            icons: {
                refresh: 'icon-refresh',
                toggle: 'glyphicon-list-alt',
                columns: 'icon-select',
                export: 'icon-export'
            },
            responseHandler: function (res) {
                $("#dsh").html(res.length);
                return res;
            },
            formatNoMatches: function () { //判断有无数据
                var imghtml = '<div class="flexed_column content_center content_alignCenter padding-20"><img src="https://static.9hive.cn/global/img/nodata.png" class="no_data"/><span class="font-size-16">暂无数据</span></div>';
                return imghtml;
            },
            formatLoadingMessage: function () {  //数据加载中样式
                return ' <div id="loading"><div id="loading-center">' +
                    '<div id="loading-center-absolute"><div class="object" id="object_one">' +
                    '</div><div class="object" id="object_two"></div><div class="object" id="object_three">' +
                    '</div><div class="object" id="object_four"></div></div></div>努力加载中...</div>'
            },
        });

    })();


</script>
</body>

</html>